package com.scsj.supermarket.presenter;

import android.util.Log;

import com.orhanobut.logger.Logger;
import com.scsj.supermarket.base.CancelMineOrderBase;
import com.scsj.supermarket.base.MineOrderDetailBase;
import com.scsj.supermarket.bean.CancelOrderBean;
import com.scsj.supermarket.bean.MineOrderDetailBean;
import com.scsj.supermarket.model.CancelMineOrderModel;
import com.scsj.supermarket.model.MineOrderDetailModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * Created by Administrator on 2018/6/26.
 */

public class CancelMineOrderPresenter extends BasePresenter implements CancelMineOrderBase.IPresenter {
    private CancelMineOrderBase.IView mView;
    private CancelMineOrderBase.IModel mModel;

    public CancelMineOrderPresenter(CancelMineOrderBase.IView mView) {
        this.mView = mView;
        mModel = new CancelMineOrderModel();
    }

    @Override
    public void deliverData(RequestBody requestBody) {
        addSubscription(mModel.getData(requestBody, new ResponseCallback<CancelOrderBean>() {
            @Override
            public void onSuccess(CancelOrderBean result) {

                if (result.getStatusCode()== 200) {
                    mView.showSuccessMsg("获取成功",result);
                    Logger.e("获取成功" + result.toString());
                } else {
                    mView.showErrorMsg(result.getMsg());
                    Logger.e("未成功" + result.toString());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("失败", msg + "");
            }
        }));
    }
}
